﻿using System;
using System.Configuration;
using Evolution.Client.ImportData.Commands;

namespace Evolution.Client.ImportData.Infrastructure
{
    public class ImportSettings : ConfigurationSection
    {
        #region variables

        private static ImportSettings instance = null;

        #endregion
        /// <summary>
        //  CommandAction:
        //    + 'ImportData': Deserialize data objects from XML files, build and send data object commands 
        //    + 'GenerateDataTemplate': Generate data objects structure to XML files.  
        /// </summary>
        [ConfigurationProperty("commandAction")]
        public ActionTypes CommandAction
        {
            get { return (ActionTypes)this["commandAction"]; }
            set { this["commandAction"] = value; }
        }

        /// <summary>
        /// Path to XMl file contains data objects that need to be import/generate data template.    
        /// </summary>
        [ConfigurationProperty("mappingFile")]
        public string MappingFile
        {
            get { return (string)this["mappingFile"]; }
            set { this["mappingFile"] = value; }
        }

        /// <summary>
        /// Folder contains XML files need to be process import
        /// </summary>
        [ConfigurationProperty("importFolder")]
        public string ImportFolder
        {
            get { return (string)this["importFolder"]; }
            set { this["importFolder"] = value; }
        }

        /// <summary>
        /// Folder contains XML files that generated from data objects
        /// </summary>
        [ConfigurationProperty("templateFolder")]
        public string TemplateFolder
        {
            get { return (string)this["templateFolder"]; }
            set { this["templateFolder"] = value; }
        }

        #region Static methods
        public static ImportSettings GetInstance()
        {
            return instance ?? (instance = ConfigurationManager.GetSection("ImportSettings") as ImportSettings);
        }

        #endregion
    }
}
